#ifndef MISC_H
#define MISC_H
#include <stdint.h>


#define BETWEEN11(_left_,_arg_,_right_) ((_left_ <= _arg_) && (_arg_ <= _right_))
#define BETWEEN01(_left_,_arg_,_right_) ((_left_ <  _arg_) && (_arg_ <= _right_))
#define BETWEEN10(_left_,_arg_,_right_) ((_left_ <= _arg_) && (_arg_ <  _right_))
#define BETWEEN00(_left_,_arg_,_right_) ((_left_ <  _arg_) && (_arg_ <  _right_))

#define CSTRING(_str_) _str_, sizeof(_str_) - 1
#define TSTRING(_type_,_str_) (_type_)_str_, sizeof(_str_) - 1


extern int32_t data_to_num(uint8_t **p2data, uint32_t *plen, uint32_t *pnumber); //will be discarded later

extern int32_t data_to_u32(uint8_t **p2data, uint32_t *plen, uint32_t *pnumber); //recomment
extern int32_t data_to_s32(uint8_t **p2data, uint32_t *plen, int32_t *pnumber); //recomment

extern int32_t data_skip(uint8_t **p2data, uint32_t *plen, uint8_t data);
extern int32_t data_to_str(uint8_t **p2data, uint32_t *plen, char **p2str, uint32_t *ps_len);
extern int32_t data_to_dqstr(uint8_t **p2data, uint32_t *plen, char **p2str, uint32_t *ps_len);
extern int32_t str_cmp(const char *pdata, uint32_t len, const char *pstr, uint32_t s_len);
extern int32_t str_all_number_pre(const char *pdata, uint32_t len);

extern int32_t bin_to_hstr(uint8_t *pdst, uint8_t *psrc, uint32_t len);
extern int32_t hstr_to_bin(uint8_t *pdst, uint8_t *psrc, uint32_t len);

extern void show_data(uint8_t *pdata, uint32_t len, uint32_t flag_hex);
extern void show_one_data(uint8_t data);
#endif
